package com.thoughtworks.annotaion.service;

import com.thoughtworks.annotaion.model.Customer;
import com.thoughtworks.annotaion.repository.CustomerRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by yrzhang on 10/8/16.
 */
@Service("customerService")
public class CustomerServiceImpl implements CustomerService {
    private CustomerRepository customerRepository;

    public CustomerServiceImpl() {

    }

    @Autowired
    public CustomerServiceImpl(CustomerRepository customerRepository) {
        System.out.println("We are using constructor injection");
        this.customerRepository = customerRepository;
    }

//    @Autowired
//    public void setCustomerRepository(CustomerRepository customerRepository) {
//        System.out.println("We are using setter injection");
//
//        this.customerRepository = customerRepository;
//    }

    public List<Customer> findAll() {
        return customerRepository.findAll();
    }

}
